package data;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tomi
 * Date: 07/10/2011
 * Time: 14:17:21
 * To change this template use File | Settings | File Templates.
 */
public class FileDataSetGenerator {
    private FileReader fr;
    public FileDataSetGenerator(String fileName) {
        try{
            fr = new FileReader(fileName);
        }catch(IOException e){
            System.out.println(e.getMessage());
        }
    }
    public List<String> createList(int i) {
        int cantPalabras = 0;
        List<String> list = new ArrayList<String>(i);
        try{
            while(cantPalabras<i){
                String s = new String();
                int a = fr.read();
                while((65<=a && a<=90)||(97<=a && a<=122)){
                    s = s.concat(new Character((char)a).toString());
                    a = fr.read();
                }
                if(!s.equals("")){
                    list.add(s);
                    cantPalabras++;
                }
            }
        }catch(IOException e){
            System.out.println(e.getMessage());
        }
        return list;
    }
    public Comparator getComparator() {
        return new Comparator<String>(){
            public int compare(String string, String string1) {
                return string.compareTo(string1);
            }
        };
    }
}